<template>
	<view>
		<scan></scan>
		<scanner></scanner>
		<sm></sm>
		<honeywell></honeywell>
		<hk></hk>
		<view class=" u-p-r-30 u-p-l-30 u-m-t-20" >
			<u-search placeholder="请输入关键词搜索" :clearabled="true" v-model="keyword" border-color="#606266" @custom="search" @search="search"></u-search>
		</view>
		<u-card padding="16">
			<view class="" slot="head">
				<view class="wrap">
					<u-row>
						<u-col span="12">
							<view class="u-m-t-5 weikaishi3 lanse">
								<span><u-icon name="order" size="30" labelSize="15px" labelColor="#000000"></u-icon>{{HxStoragePutParam.storageNumber}}</span>
							</view>
						</u-col>
					</u-row>
					<u-row >
						<u-col span="12">
							<view class="weikaishi3">
								<span><u-icon name="account" size="29" labelSize="14px" labelColor="#000000" label="发货客户" color="#000000"></u-icon>：{{HxStoragePutParam.setUnit}}</span>
							</view>
						</u-col>
					</u-row>
					<u-row >
						<u-col span="12">
							<view class="weikaishi3">
								<span><u-icon name="home" size="29" labelSize="14px" labelColor="#000000" label="收货仓库"></u-icon>：{{HxStoragePutParam.getWarehouse}}</span>
							</view>
						</u-col>
					</u-row>
					<u-row >
						<u-col span="7" >
							<view class="weikaishi6">
								<span><u-icon name="clock" size="29" labelSize="14px" labelColor="#000000" label="数量" color="#000000"></u-icon>：{{HxStoragePutParam.putNum}}/{{HxStoragePutParam.putVolume}}方</span>
							</view>
						</u-col>
						<u-col span="5" v-if="HxStoragePutParam.putNum == HxStoragePutParam.realNum">
							<view class="weikaishi6 yiwancheng">
								<span><u-icon name="checkmark-circle" size="29" labelSize="14px" labelColor="#00c300" label="实入" color="#00c300"></u-icon>：{{HxStoragePutParam.realNum}}</span>
							</view>
						</u-col>
						<u-col span="5" v-else>
							<view class="weikaishi6">
								<span><u-icon name="checkmark-circle" size="29" labelSize="14px" labelColor="#000000" label="实入" color="#000000"></u-icon>：{{HxStoragePutParam.realNum}}</span>
							</view>
						</u-col>
					</u-row>
					<u-row >
						<u-col span="12">
							<view class="weikaishi6">
								<span><u-icon name="checkmark-circle" size="29" labelSize="14px" labelColor="#000000" label="商品数"></u-icon>：{{HxStoragePutParam.goodsNum}}</span>
							</view>
						</u-col>
					</u-row>
					<u-row >
						<u-col span="12">
							<view class="weikaishi6">
								<span><u-icon name="calendar" size="29" labelSize="14px" labelColor="#000000" label="预约时间"></u-icon>：{{HxStoragePutParam.yuyueTime}}</span>
							</view>
						</u-col>
					</u-row>
				</view>
			</view>
			<view class="" slot="body">
				<view class="wrap">
					<u-row v-for="(item,index) in dataList" :key="index" @click="todetailed(item)">
						<u-col span="9" text-align="left">
							<view class="weikaishi lanse u-m-t-25 huanhang">
								<span>{{item.goodsName}}({{item.unit}})</span>
							</view>
						</u-col>
						<u-col span="3" text-align="right" v-if="item.realNum == item.num">
							<view class="weikaishi yiwancheng u-m-t-25">
								<span>完成收货</span>
							</view>
						</u-col>
						<u-col span="3" text-align="right" v-else-if="item.realNum > 0 && item.realNum < item.num">
							<view class="weikaishi jinxingzhong u-m-t-25">
								<span>部分收货</span>
							</view>
						</u-col>
						<u-col span="3" text-align="right" v-else>
							<view class="weikaishi u-m-t-25">
								<span>未收货</span>
							</view>
						</u-col>
						<u-col span="8" text-align="left">
							<view class="weikaishi u-m-t-4">
								<span>条码：{{item.goodsPcode69}}</span>
							</view>
						</u-col>
						<u-col span="4" text-align="right">
							<view class="weikaishi u-m-t-4">
								<span>实入：{{item.realNum}}</span>
							</view>
						</u-col>
						<u-col span="8" text-align="left">
							<view class="weikaishi u-m-t-4">
								<span>规格：{{item.goodsSpecs}}</span>
							</view>
						</u-col>
						<u-col span="4" text-align="right">
							<view class="weikaishi u-m-t-4">
								<span>数量：{{item.num}}</span>
							</view>
						</u-col>
						<u-col span="12" text-align="center">
							<view class="jiange">
							</view>
						</u-col>
					</u-row>
				</view>
			</view>
		</u-card>
		<view>
			<u-toast ref="uToast" />
		</view>
	</view>
</template>
<script>
	import scan from "@/components/uni-scan/scan.vue"
	import scanner from "@/components/uni-scan/scanner.vue"
	import sm from "@/components/uni-scan/sm.vue"
	import honeywell from "@/components/uni-scan/honeywell.vue"
	import hk from "@/components/uni-scan/hk.vue"
	
	export default {
		components: {
			scanner,
			scan,
			sm,
			honeywell,
			hk
		},
		data() {
			return {
				storageNumber:'',
				HxStoragePutParam: {},
				dataList: [],
				keyword:'',
			}
		},
		onLoad(open) {
			//#ifdef H5 || APP-PLUS
			this.flex = 'u-flex'
			//#endif
			
			this.storageNumber = open.storageNumber
		},
		onShow() {
			this.refresh()
			let that = this
			uni.$off('scan')
			uni.$on('scan', function(res) {
				console.log('扫码结果：', res.codeStr);
				that.keyword = res.codeStr;
				that.refresh();
			})
			uni.$off('scanner') // 每次进来先 移除全局自定义事件监听器
			uni.$on('scanner', function(res) {
				console.log('扫码结果：', res.code);
				that.keyword = res.code;
				that.refresh();
			})
			uni.$off('sm') // 每次进来先 移除全局自定义事件监听器
			uni.$on('sm', function(res) {
				console.log('扫码结果：', res.code);
				that.keyword = res.code;
				that.refresh();
			})
			uni.$off('honeywell') // 每次进来先 移除全局自定义事件监听器
			uni.$on('honeywell', function(res) {
				console.log('扫码结果：', res.code);
				that.keyword = res.code;
				that.refresh();
			})
			uni.$off('hk') // 每次进来先 移除全局自定义事件监听器
			uni.$on('hk', function(res) {
				console.log('扫码结果：', res.code);
				that.keyword = res.code;
				that.refresh();
			})
			
		},
		onPullDownRefresh() {
			this.refresh()
			uni.stopPullDownRefresh()
		},
		methods: {
			todetailed(e){
				this.$Router.push({ 
					name: 'hx_storage_put_quality_goods_detailed',
					params: { storageNumber:e.storageNumber,goodsId:e.goodsId},
				})
			},
			refresh(){
				uni.showLoading({
					title: '加载中...'
				})
				this.$http.post('/rest/HxStoragePut/storage',{
				},{
					params: {
						storageNumber: this.storageNumber,
					},
					header: {
						'Authorization' :uni.getStorageSync('token'),
					}
				}).then(res => {
					if(res.data.data != null && res.data.data != ''){
						this.HxStoragePutParam = res.data.data
						this.$http.post('/rest/HxStoragePut/detailedSumlist',{
						},{
							params: {
								storageNumber: this.storageNumber,
								keyword: this.keyword
							},
							header: {
								'Authorization' :uni.getStorageSync('token'),
							}
						}).then(res => {
							this.dataList = res.data.data
							// if(this.dataList.length === 1){
							// 	this.toGoods(this.dataList[0]);
							// }
						})
					}
				})
				uni.hideLoading()
			},
			search(e){
				this.refresh()
			},
		},
	}
</script>
<style lang="scss">
	.huanhang{
		word-break:break-all;
	}
	.jiange{
		border-bottom: 1px solid #e1e1e1;
	}
</style>